package com.xcity.game.arena;

import com.xcity.game.arena.offline.OfflineArenaHandler;
import com.xcity.game.arena.online.OnlineArenaHandler;

import naga.x.service.Service;
import naga.x.service.ServiceException;
import naga.x.util.ServiceUtils;

/**
 * 竞技场
 * @author yang.li
 *
 */
public class ArenaService implements Service {

	protected ArenaHandler[] handlers;
	
	@Override
	public void startup() throws ServiceException {
		try {
			handlers = new ArenaHandler[] {
					ServiceUtils.newPacketHandlerProxy(OfflineArenaHandler.class),
					ServiceUtils.newPacketHandlerProxy(OnlineArenaHandler.class),
			};
			for (ArenaHandler handler : handlers) {
				handler.startup();
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	@Override
	public void shutdown() throws ServiceException {
		for (ArenaHandler handler : handlers) {
			handler.shutdown();
		}
	}

	@Override
	public String getId() {
		return getClass().getName();
	}

}
